package org.lql.chaos.mq.rabbitmq.controller;

import org.lql.chaos.mq.rabbitmq.pojo.OrderInfo;
import org.lql.chaos.mq.rabbitmq.producer.OrderMessageProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: liangqinglong
 * @date: 2025-08-09 00:34
 * @description:
 **/
@RestController
@RequestMapping("/order")
public class OrderController {

	@Autowired
	private OrderMessageProducer orderMessageProducer;

	@RequestMapping("/send")
	public String sendOrderMessage() {
		OrderInfo orderInfo = new OrderInfo();
		orderInfo.setOrderId("123456");
		orderInfo.setOrderName("测试订单-全局超时时间ttl");
		orderMessageProducer.sendOrderMessage(orderInfo);
		return "success";
	}

	@RequestMapping("/send-order-expiration")
	public String sendOrderMessageWithExpiration() {
		OrderInfo orderInfo = new OrderInfo();
		orderInfo.setOrderId("123457");
		orderInfo.setOrderName("测试订单-单独超时时间ttl");
		orderMessageProducer.sendOrderMessageWithExpiration(orderInfo, 10000);
		return "success";
	}
}
